package qx.hyj.demos.controller;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import qx.hyj.demos.entity.User;
import qx.hyj.demos.mapper.Usermapper;
import qx.hyj.demos.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.Resource;

@RestController
@RequestMapping("/Demo/users")
@ApiOperation(value = "用户管理")
public class UserController {
    @Resource
    private UserService userService;

    @PostMapping("/adduser")
    @ApiOperation(value = "添加用户")
    public User addUser(@ApiParam(value = "用户信息") @RequestBody User user) {
        Integer id = userService.addUser(user);
        if (id != null) {
            return user;
        } else {
            return null;
        }
    }
    @PostMapping("/getuser")
    @ApiOperation(value = "获取用户")
    public User getUser(@ApiParam(value = "用户id") @RequestParam Integer id) {
        User user = userService.getUser(id);
        return user;
    }


}